/*
ID: icerupt1
PROG: nuggets
LANG: C++11
*/

/* solution
 *
 * great.
 * analysis: The only way for there to be no bound to the largest number
 * which is unobtainable is if the greatest common divisor of the package
 * sizes is greater than 1, so first check for that.
 *
 * Given two relatively prime numbers N and M, the largest number that
 * you cannot make is NM - M - N.
 *
*/
#include <fstream>
#include <iostream>

std::ifstream fin {"nuggets.in" };
std::ofstream fout{"nuggets.out"};

int const maxl = 65024 + 4;
int const maxn = 11;
bool f[maxl];
int da[maxn];
int n;

int main()
{
	fin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++) fin >> da[i];
	f[0] = true;
	for (int i = 1; i < maxl; i++) {
		for (int j = 0; j < n; j++)
			if (i >= da[j] && f[i - da[j]]) {
				f[i] = true;
				break;
			}
		if (!f[i]) ans = i;
	}
	if (ans >= maxl-1) ans = 0;
	std::cout << ans << '\n';
	fout << ans << '\n';
}

